<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:t="http://www.pagac.cz/jsf">
 <h:head></h:head>
 <h:body>
    <ui:composition template="/WEB-INF/templates/template-insystem.xhtml">

        <!-- Toolbar -->
        <ui:define name="toolbar-place">
            <t:toolbar>
                <t:icon iconName="home" action="goHome" label="#{msgs['toolbar.home']}" />
                <t:icon iconName="back" action="project/list" label="#{msgs['toolbar.back']}" />
                <t:icon iconName="print" action="printPage" label="#{msgs['toolbar.print']}" />
            </t:toolbar>
        </ui:define>

       <ui:define name="content-title">
           <h1>#{msgs["project.page-title"]}</h1>
       </ui:define>

        <ui:define name="content">
            <c:if test="#{projectManager.newProject}" />
            <p>
              #{msgs["register.welcome-text"]}
            </p>

            <div>
                    <fieldset>
                        <legend>#{msgs["project.projectValues"]}</legend>
                         <h:panelGrid columns="3">
                            <h:outputLabel for="name">#{msgs["project.name"]} *</h:outputLabel>
                            <h:inputText id="name" required="true" maxlength="32" value="#{projectManager.project.name}" requiredMessage="#{msgs['project.requiredName']}">
                                <f:validateLength minimum="3" maximum="32" />
                            </h:inputText>
                            <h:message for="name" />

                            <h:outputLabel for="note">#{msgs["project.note"]}</h:outputLabel>
                            <h:inputTextarea cols="30" rows="4" id="note" required="false" value="#{projectManager.project.note}"/>
                            <h:message for="note" />

                            <h:outputLabel for="customer">#{msgs["project.customer"]} *</h:outputLabel>
                            <h:selectOneMenu id="customer" required="true" value="#{projectManager.project.idCustomer}">
                                <f:selectItem itemValue="0" itemLabel="#{msgs['project.implicitCustomer']}" />
                                <f:selectItems value="#{customerManager.selectList}" />
                                <f:ajax execute="@this" event="valueChange"  render="rateType price" listener="#{projectManager.changeRate}" onevent="showIndicator" />
                            </h:selectOneMenu>
                            <h:message for="customer" />

                            <h:outputLabel for="time">#{msgs["project.timeEstimation"]}</h:outputLabel>
                            <h:inputText id="time" maxlength="11" required="false" value="#{projectManager.project.timeEstimation}" requiredMessage="#{msgs['project.requiredName']}">
                               <f:validateLongRange minimum="0"/>
                               <f:convertNumber type="number" maxIntegerDigits="11"/>
                            </h:inputText>
                            <h:message for="time" />

                          </h:panelGrid>
                    </fieldset>
                    <br/>
                    <fieldset>
                        <legend>#{msgs["project.rateValues"]}</legend>

                        <h:panelGrid columns="3">
                            <h:outputLabel for="rateType" >#{msgs["project.rateType"]} *</h:outputLabel>
                            <h:selectOneMenu id="rateType" value="#{projectManager.project.rateType}">
                                <f:selectItem itemValue="h" itemLabel="#{msgs['project.rateType.hours']}"></f:selectItem>
                                <f:selectItem itemValue="t" itemLabel="#{msgs['project.rateType.tariff']}"></f:selectItem>
                                <f:selectItem itemValue="p" itemLabel="#{msgs['project.rateType.project']}"></f:selectItem>
                            </h:selectOneMenu>
                            <h:message for="rateType" />

                            <h:outputLabel for="price">#{msgs["project.pricePerRateUnit"]} *</h:outputLabel>
                            <h:inputText id="price"  required="false" maxlength="11" value="#{projectManager.project.pricePerRateUnit}">
                               <f:validateDoubleRange minimum="0"/>
                               <f:convertNumber type="number" maxIntegerDigits="11"/>
                            </h:inputText>
                            <h:message for="price" />
                        </h:panelGrid>
                    </fieldset>
                    <br />
                    <h:commandButton action="#{projectManager.create}" type="submit" value="#{msgs['project.submit']}"></h:commandButton>
            </div>

       </ui:define>
    </ui:composition>

</h:body>
</html>
